from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical, users, orders, group, admin
from .views import skus, specs, images, spus, options, permission
from rest_framework.routers import DefaultRouter

urlpatterns = [
    #  登录路由
    url(r'^authorizations/$', obtain_jwt_token),
    #  -------数据统计---------
    # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    #  日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    #  日活跃用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    #  日下单用户量统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    #  月增用户统计量
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    #  日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    # -------用户管理---------
    url(r'^users/$', users.UserView.as_view()),

    # -------规格路由表--------
    url(r'goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    url(r'^goods/specs/simple/$', options.OptionSimple.as_view()),

    # -------获取sku的id--------
    url(r'skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    # -------获取三级分类信息--------
    url(r'skus/categories/$', skus.SKUCategorieView.as_view()),

    # -------获取spu表名称数据--------
    # url(r'goods/simple/$', skus.SPUSimpleView.as_view()),  # 此行代码和上面规格路由表的作用是一样的

    # -------获取spu商品规格信息--------
    url(r'goods/(?P<pk>\d+)/specs/$', skus.SPUSpecView.as_view()),

    #  获取品牌信息
    url(r'goods/brands/simple/$', spus.SPUSView.as_view({'get': 'brand'})),

    #  获取一级分类
    url(r'goods/channel/categories/$', spus.SPUSView.as_view({'get': 'channel'})),

    #  获取二级三级分类
    url(r'goods/channel/categories/(?P<pk>\d+)/$', spus.SPUSView.as_view({'get': 'channels'})),

    #  上传图片
    url(r'goods/images/$', spus.SPUSView.as_view({'post': 'image'})),

    #  保存spu数据
    # url(r'goods/$', spus.SPUGoodsView.as_view({'post': 'list'}))  # 自动路由会生成这个路由的

    #  获取修改商品的详情信息
    # url(r'goods/channel/categories/(?P<pk>\d+)/$', spus.SKUGoodsView.as_view({'get': 'list'})),

    #  获取权限类型列表数据
    url(r'permission/content_types/$', permission.PermissionView.as_view({'get': 'content_types'})),

    #  保存分组表数据
    url(r'permission/simple/$', group.GroupView.as_view({'get': 'simple'})),

    #  权限分组表路由
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),

]
#  规格表路由*****************************
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='specs')
# print(router.urls)
urlpatterns += router.urls

#  图片查询路由****************************
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='images')
# print(router.urls)
urlpatterns += router.urls

#  sku表查询路由****************************
router = DefaultRouter()
router.register('skus', skus.SKUGoodsView, base_name='sku')
urlpatterns += router.urls

#  查询获取SPU表列表数据
router = DefaultRouter()
router.register('goods', spus.SPUGoodsView, base_name='goods')
# print(router.urls)
urlpatterns += router.urls

router = DefaultRouter()
router.register('specs/options', options.OptionsView, base_name='options')
# print(router.urls)
urlpatterns += router.urls

#  查询获取订单管理列表数据
router = DefaultRouter()
router.register('orders', orders.OrdersView, base_name='orders')
# print(router.urls)
urlpatterns += router.urls

#  用户权限管理
router = DefaultRouter()
router.register('permission/perms', permission.PermissionView, base_name='perms')
# print(router.urls)
urlpatterns += router.urls


#  分组表管理
router = DefaultRouter()
router.register('permission/groups', group.GroupView, base_name='groups')
# print(router.urls)
urlpatterns += router.urls

# --------管理员路由--------
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, base_name='admin')
# print(router.urls)
urlpatterns += router.urls
